/*
 Copyright (c) Whitemice Consulting, 2007, 2008, 2009
 Adam Tauno Williams <awilliam@whitemice.org>
 License: MIT/X11

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/
using System;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using Whitemice.ZOGI;
using Whitemice.ZOGI.GtkWidgets;
using Gtk;
using GLib;

namespace Whitemice.Consonance
{  
	/* Application bootstrap class */
	internal static class Consonance
	{
		public static List<Whitemice.ZOGI.Task>             inboundTasks;
		public static Queue                                 eventQueue;
		public static UserProfile                           profile;
		public static MainWindow                            mainWindow;
		public static GLib.IdleHandler                      idleHandler;
		public static int                                   idleCount;
	
		// Application entry point 
		[STAThread]
		public static void Main (string[] args)
		{
		  // Initialize ZOGI environment 
		  Server.Initialize();
		  GUI.SetColorKey("evenRowBackground", new Gdk.Color(198, 226, 225)); /* Slate#1 */
			GUI.SetColorKey("oddRowBackground", new Gdk.Color(185, 211, 238)); /* Slate#2 */
			GUI.SetColorKey("overdueForeground",  new Gdk.Color(255, 0, 0)); /* Red */
			GUI.SetColorKey("upcomingForeground", new Gdk.Color(72, 61, 139)); /* Dark Slate Blue */
			GUI.SetColorKey("defaultForeground",  new Gdk.Color(0, 0, 0)); /* Black */
		  //eventQueue = Queue.Synchronized(new Queue(8192));
      eventQueue = new Queue(8192);
		  
		  // Initialize Consonance shared data stores 
			inboundTasks = new List<Whitemice.ZOGI.Task>(4096);
			idleCount = 0;
			
		  // Statup the Gtk application 
			Application.Init();
			mainWindow = new MainWindow ();
			GUI.MainWindow = mainWindow;
			mainWindow.Show();
			Registry.StoreObject("GUI/MainWindow", mainWindow);
			Application.Run ();
		} // end Main;  Application entry point
		
		/// <summary>
		/// Shutdown and exit the application
		/// </summary>
		public static void Quit()
		{
			Application.Quit();
		} // end Quit
	} // end Class
} // end namespace